﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace TicketManagement
{
    public partial class 注册OTA平台 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        

        protected void Button2_Click(object sender, EventArgs e)
        {
            
            int username = int.Parse(this.username.Text);
            string password = this.password.Text;
            int identity = 3;

            int OTANumber = int.Parse(this.OTANumber.Text);
            string OTAName = this.OTAname.Text;
            long tel = long.Parse(this.telephone.Text);

            string connStr = "server=121.43.119.97;user id=root;password=h666niub;persistsecurityinfo=True;database=ticket_management_system";
            MySqlConnection conn = new MySqlConnection(connStr);
            conn.Open();
            //System.Diagnostics.Debug.WriteLine(connStr);

            try
            {
                string insertStr = "INSERT INTO user(userName,password,identity_id) VALUES (" + username + "," + password + "," + identity + ")";
                MySqlCommand cmd = new MySqlCommand(insertStr, conn);
                cmd.ExecuteScalar();

                string insert_OTA = "INSERT INTO otaplatform(OTANumber,OTAName,telephone) VALUES (" + OTANumber + "," + OTAName + "," + tel + ")";
                MySqlCommand cmd2 = new MySqlCommand(insert_OTA, conn);
                cmd2.ExecuteScalar();
                
                MessageBox.Show("注册成功！");
                conn.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }
    }
}